<?php
/**
 * polwebgis
 * 
 * This file is part of polwebgis.
 *
 * @copyright   Copyright (c) 2012 Dominik Janisch (http://www.joanneum.at)
 * @lastmodified    $LastChangedDate: 2012-03-07 09:15:12 +0000 (Wed, 07 Mar 2012) $
 * @revision    $Revision: 160 $ 
 */

class InputMapperGateway extends TableDataGateway
{           
        
    public function __construct()
    {
        $this->establishConnection();
    }
        
    public function __destruct(){}
    
    public function getContiguity($e_id)
    {
        $stmt = $this->database_connection_->newStatement('SELECT gid, n_gid FROM contiguity_weight_table where e_id=:e_id');
        $stmt->bindValue(':e_id', $e_id, PDO::PARAM_INT);
        $stmt->execute();
        $arr_return = array();
        while($row = $stmt->fetch(PDO::FETCH_ASSOC))
            $arr_return[] = $row;
        return $arr_return;
    }
    
    public function getRegions($shape_id)
    {
        $stmt = $this->database_connection_->newStatement('SELECT gid, region_id, region FROM shape_'.pg_escape_string($shape_id).' order by region_id');
        $stmt->execute();
        $arr_return = array();
        while($row = $stmt->fetch(PDO::FETCH_ASSOC))
        {
            $arr_return[$row['gid']]['region'] = $row['region'];
            $arr_return[$row['gid']]['region_id'] = $row['region_id'];
        }
        return $arr_return;
    }
}

?>
